package com.eagle.functioninterface;

import org.junit.Test;

import java.util.function.DoubleUnaryOperator;
import java.util.function.IntUnaryOperator;
import java.util.function.LongUnaryOperator;

/**
 * 这类函数式接口的命名规则是:入参和出参类型+UnaryOperator
 * {@link java.util.function.IntUnaryOperator}
 * {@link java.util.function.DoubleUnaryOperator}
 * {@link java.util.function.LongUnaryOperator}
 * @author qinlinsen
 */
public class OutputUnaryOperatorTest15 {
    @Test
    public void testIntUnaryOperator(){
        IntUnaryOperator f = x -> x +3;
        final int result = f.applyAsInt(5);
        System.out.println(result);
    }

    @Test
    public void testDoubleUnaryOperator(){
        DoubleUnaryOperator f = x -> x +3.0;
        final double result = f.applyAsDouble(5.5);
        System.out.println(result);
    }


    @Test
    public void testLongUnaryOperator(){
        LongUnaryOperator f = x -> x * 8;
        final long result = f.applyAsLong(4L);
        System.out.println(result);
    }
}
